var express = require('express');
var router = express.Router();
var ManagerModel = require('../models/manager');

router.post('/', function(req, res, next) {
    var token = req.cookies.token;
    ManagerModel.findOneAndUpdate({token:token},{$set:{token:''}},function(err,data){
        if(err){
            return err;
        }
        if(data||data['name']){
            console.log(data);
            res.cookie('token','');
            res.json({'success':true});
        }else{
            res.json({'success':false});
        }
        
    })
  
});

module.exports = router;